
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>single_bubble_model &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for single_bubble_model</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Single Bubble Model</span>
<span class="sd">===================</span>

<span class="sd">Simulate the trajectory of a particle rising through the water column</span>

<span class="sd">This module defines the classes, methods, and functions necessary to simulate</span>
<span class="sd">the rise of a single particle (bubble, droplet or solid particle) through the</span>
<span class="sd">water column. The ambient water properties are provided through the</span>
<span class="sd">`ambient.Profile` class object, which contains a netCDF4-classic dataset of</span>
<span class="sd">CTD data and the needed interpolation methods. The `dbm` class objects</span>
<span class="sd">`dbm.FluidParticle` and `dbm.InsolubleParticle` report the properties and</span>
<span class="sd">behavior of the particle during the simulation. An interface to the `dbm`</span>
<span class="sd">objects is provided by the Particle class objects defined in</span>
<span class="sd">`dispersed_phases`.</span>

<span class="sd">Notes</span>
<span class="sd">-----</span>
<span class="sd">This model solves for the trajectory `vec(x)` by the simple transport</span>
<span class="sd">equation::</span>

<span class="sd">    d vec(x) / dt = vec(u)</span>

<span class="sd">where `vec(u)` is the vector velocity of the particle, which may include the</span>
<span class="sd">rise velocity and an ambient current. The rise velocity depends on the</span>
<span class="sd">particle size, which changes with pressure (if compressible) and as a result</span>
<span class="sd">of mass transfer (when soluble). Hence, this equation is usually coupled to a</span>
<span class="sd">system of equations for the change in mass of each chemical component in the</span>
<span class="sd">particle `m_i`, given by::</span>

<span class="sd">    d (m_i) / dt = - beta * A * (Cs - C)</span>

<span class="sd">where `Cs` is the local solubility of component `i` and `C` is the local</span>
<span class="sd">concentration of component `i` in the surrounding water; `beta` is the mass</span>
<span class="sd">transfer coefficient and `A` is the surface area.  Methods to compute</span>
<span class="sd">`beta`, `Cs`, and `A` are provided in the `dbm` module.  Since source fluids</span>
<span class="sd">may have different temperature than the ambient, heat transfer is also</span>
<span class="sd">modeled::</span>

<span class="sd">    d H / dt = - rho_p * cp * A * beta_T * (T - Ta)</span>

<span class="sd">where `H` is the heat content, given by `m_p * cp * T`; `beta_T` is the heat</span>
<span class="sd">transfer coefficient and `m_p` is the total mass of the particle.  Since some</span>
<span class="sd">mass is lost due to dissolution, the particle temperature must be adjusted</span>
<span class="sd">by::</span>

<span class="sd">    d H / dt = cp * d (m_p) / dt * T        # Note d (m_p) / dt &lt; 0</span>

<span class="sd">and for the heat of solution, using::</span>

<span class="sd">    d H / dt = sum (d (m_i) /dt * dH_solR_i * Ru / M_i)</span>

<span class="sd">where `dH_solR` is the enthalpy of solution divided by the universal gas</span>
<span class="sd">constant (`Ru`) and `M_i` is the molecular weight of constituent `i`.</span>

<span class="sd">When the particle becomes very small, the heat transfer and dissolution</span>
<span class="sd">become unstable, leading to rapid oscillations in the predicted particle</span>
<span class="sd">temperature.  To avoid this problem, this module accounts for heat transfer</span>
<span class="sd">until the particle temperature reaches equilibrium with the seawater (which</span>
<span class="sd">happens very quickly).  Thereafter, the particle is assumed to be equal to</span>
<span class="sd">the temperature of the ambient water.</span>

<span class="sd">The equations for heat and mass transfer and for slip velocity are</span>
<span class="sd">discontinuous at the boundaries between particle shapes (e.g., ellipsoid and</span>
<span class="sd">spherical cap, etc.), and this can sometimes lead to the solution getting</span>
<span class="sd">stuck at the shape transition. The convergence criteria for the ODE solver are</span>
<span class="sd">set at an optimal compromise for accuracy and for allowing a diverse range of</span>
<span class="sd">particles to be simulated. Nonetheless, there are situations where these</span>
<span class="sd">discontinuities may still break the solution.</span>

<span class="sd">Finally, if the diameter of a fluid particle is observed to rapidly increase,</span>
<span class="sd">this is usually associated with a phase change from liquid to gas.  The</span>
<span class="sd">diagnostic plots help to identify these effects by plotting the state space</span>
<span class="sd">together with several descriptive variables, including diameter, density,</span>
<span class="sd">and shape.  However, there is no mechanism in this module to allow a droplet</span>
<span class="sd">to break up into multiple bubbles.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="c1"># S. Socolofsky, November 2014, Texas A&amp;M University &lt;socolofs@tamu.edu&gt;.</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span><span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span><span class="p">,</span> <span class="n">print_function</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">model_share</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">seawater</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">ambient</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">dbm</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">dispersed_phases</span>

<span class="kn">from</span> <span class="nn">netCDF4</span> <span class="kn">import</span> <span class="n">Dataset</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="c1"># mpl imports moved to plotting functions</span>
<span class="c1"># import matplotlib.pyplot as plt</span>
<span class="c1"># import matplotlib as mpl</span>
<span class="kn">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</span>
<span class="kn">from</span> <span class="nn">scipy</span> <span class="kn">import</span> <span class="n">integrate</span>
<span class="kn">from</span> <span class="nn">warnings</span> <span class="kn">import</span> <span class="n">warn</span>
<span class="kn">import</span> <span class="nn">os</span>


<div class="viewcode-block" id="Model"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.html#single_bubble_model.Model">[docs]</a><span class="k">class</span> <span class="nc">Model</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Master class object for controlling and post-processing the simulation</span>

<span class="sd">    This is the main program interface, and the only object or function in</span>
<span class="sd">    this module that the user should call.  At instantiation, the model</span>
<span class="sd">    parameters and the ambient water column data are organized.  For a given</span>
<span class="sd">    simulation, the user passes a `dbm` particle object and its initial</span>
<span class="sd">    conditions (e.g., mass, temperature, location) to the `simulate` method,</span>
<span class="sd">    and the object computes the trajectory and plots the resulting path and</span>
<span class="sd">    particle properties.  The simulation results can be stored to and loaded</span>
<span class="sd">    from a netCDF file using the `save_sim` and `load_sim` methods.  An</span>
<span class="sd">    ascii table of data for the state space for reading into other programs</span>
<span class="sd">    (e.g., Matlab) can be output using the `save_txt` method.  The object</span>
<span class="sd">    can only store simulation results in its attribute variables for one</span>
<span class="sd">    simulation at a time.  Each time a new simulation is run or a past</span>
<span class="sd">    simulation results file is loaded, the current simulation (if present) is</span>
<span class="sd">    overwritten.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object, default = None</span>
<span class="sd">        An object containing the ambient CTD data and associated methods.</span>
<span class="sd">        The netCDF dataset stored in the `ambient.Profile` object may be open</span>
<span class="sd">        or closed at instantiation.  If open, the initializer will close the</span>
<span class="sd">        file since this model does not support changing the ambient data once</span>
<span class="sd">        initialized.</span>
<span class="sd">    simfile: str, default = None</span>
<span class="sd">        File name of a netCDF file containing the results of a previous</span>
<span class="sd">        simulation run.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Ambient CTD data for the model simulation</span>
<span class="sd">    p : `ModelParams` object</span>
<span class="sd">        Set of model parameters not adjustable by the user</span>
<span class="sd">    sim_stored : bool</span>
<span class="sd">        Flag indicating whether or not simulation results exist in the object</span>
<span class="sd">        namespace</span>
<span class="sd">    particle : `dispersed_phases.SingleParticle` object</span>
<span class="sd">        Interface to the `dbm` module and container for particle-specific</span>
<span class="sd">        parameters</span>
<span class="sd">    t : ndarray</span>
<span class="sd">        Times (s) associated with the state space</span>
<span class="sd">    y : ndarray</span>
<span class="sd">        State space along the trajectory of the particle</span>
<span class="sd">    z0 : float</span>
<span class="sd">        The release depth (m)</span>
<span class="sd">    x0 : float, default = 0.</span>
<span class="sd">        The release x-coordinate (m)</span>
<span class="sd">    y0 : float, default = 0.</span>
<span class="sd">        The release y-coordinate (m)</span>
<span class="sd">    de : float</span>
<span class="sd">        Initial diameter of the particle (m)</span>
<span class="sd">    yk : ndarray</span>
<span class="sd">        Initial mole fractions of each chemical component (--)</span>
<span class="sd">    T0 : float, optional</span>
<span class="sd">        Initial temperature (K) of the particle at release</span>
<span class="sd">    K : float, default = 1.</span>
<span class="sd">        Mass transfer reduction factor (--)</span>
<span class="sd">    K_T : float, default = 1.</span>
<span class="sd">        Heat transfer reduction factor (--)</span>
<span class="sd">    fdis : float, default = 1.e-6</span>
<span class="sd">        Remainder fraction that turns off dissolution for each component (--)</span>
<span class="sd">    delta_t : float, default = 0.1 s</span>
<span class="sd">        Maximum time step to use (s) in the simulation output</span>

<span class="sd">    See Also</span>
<span class="sd">    --------</span>
<span class="sd">    simulate, save_sim, load_sim</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    The `Model` object will be initialized either with the `profile` data</span>
<span class="sd">    making it ready to start a new simulation or with the results of a</span>
<span class="sd">    previous simulation stored in `simfile`.</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="Model.__init__"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.html#single_bubble_model.Model.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">simfile</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">Model</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">profile</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># Create a Model object from a saved file</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">load_sim</span><span class="p">(</span><span class="n">simfile</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Create a new Model object</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="o">=</span> <span class="n">profile</span>
            <span class="n">profile</span><span class="o">.</span><span class="n">close_nc</span><span class="p">()</span>

            <span class="c1"># Enter the model parameters that the user cannot adjust</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span> <span class="o">=</span> <span class="n">ModelParams</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">False</span></div>

<div class="viewcode-block" id="Model.simulate"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.simulate.html#single_bubble_model.Model.simulate">[docs]</a>    <span class="k">def</span> <span class="nf">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">X0</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">yk</span><span class="p">,</span> <span class="n">T0</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">K</span><span class="o">=</span><span class="mf">1.</span><span class="p">,</span> <span class="n">K_T</span><span class="o">=</span><span class="mf">1.</span><span class="p">,</span>
                 <span class="n">fdis</span><span class="o">=</span><span class="mf">1.e-6</span><span class="p">,</span> <span class="n">t_hyd</span><span class="o">=</span><span class="mf">0.</span><span class="p">,</span> <span class="n">lag_time</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">delta_t</span><span class="o">=</span><span class="mf">0.1</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Simulate the trajectory of a particle from given initial conditions</span>

<span class="sd">        Simulate the trajectory of a particle (bubble, droplet or solid</span>
<span class="sd">        particle) until the particle dissolves or until it reaches the free</span>
<span class="sd">        surface.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        particle : `dbm.FluidParticle` or `dbm.InsolubleParticle` object</span>
<span class="sd">            Object describing the properties and behavior of the particle.</span>
<span class="sd">        X0 : float or ndarray</span>
<span class="sd">            The release localtion (x0, y0, z0) depth (m) of the particle in</span>
<span class="sd">            the simulation.  If float, x0 = y0 = 0 is assumed.</span>
<span class="sd">        de : float</span>
<span class="sd">            Initial diameter of the particle (m)</span>
<span class="sd">        yk : ndarray</span>
<span class="sd">            Initial mole fractions of each component in the particle (--)</span>
<span class="sd">        T0 : float, optional</span>
<span class="sd">            Initial temperature (K) of the particle at release if not equal</span>
<span class="sd">            to the temperature of the surrounding fluid.  If omitted, the</span>
<span class="sd">            model will set T0 to the ambient temperature.</span>
<span class="sd">        K : float, default = 1.</span>
<span class="sd">            Mass transfer reduction factor (--). Pre-multiplies the mass</span>
<span class="sd">            transfer coefficients providing amplification (&gt;1) or retardation</span>
<span class="sd">            (&lt;1) of the dissolution.</span>
<span class="sd">        K_T : float, default = 1.</span>
<span class="sd">            Heat transfer reduction factor (--). Pre-multiplies the heat</span>
<span class="sd">            transfer coefficient providing amplification (&gt;1) or retardation</span>
<span class="sd">            (&lt;1) of the heat flux.</span>
<span class="sd">        fdis : float, default = 1.e-6</span>
<span class="sd">            Fraction of the initial total mass remaining (--) for each</span>
<span class="sd">            component in the particle when the particle should be considered</span>
<span class="sd">            dissolved.</span>
<span class="sd">        t_hyd : float, default = 0.</span>
<span class="sd">            Hydrate film formation time (s).  Mass transfer is computed by clean</span>
<span class="sd">            bubble methods for t less than t_hyd and by dirty bubble methods</span>
<span class="sd">            thereafter.  The default behavior is to assume the particle is dirty</span>
<span class="sd">            or hydrate covered from the release.</span>
<span class="sd">        lag_time : bool, default = True</span>
<span class="sd">            flag indicating whether the biodegradation rates should include</span>
<span class="sd">            a lag time (True) or not (False).  Default value is True.</span>
<span class="sd">        delta_t : float, default = 0.1 s</span>
<span class="sd">            Maximum time step to use (s) in the simulation.  The ODE solver</span>
<span class="sd">            in `calculate_path` is set up with adaptive step size integration,</span>
<span class="sd">            so in theory this value determines the largest step size in the</span>
<span class="sd">            output data, but not the numerical stability of the calculation.</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        post_process, calculate_path, plot_state_space</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method fills the object attributes `particle`, `t` and `y`</span>
<span class="sd">        following successful simulation of the particle trajectory.  It also</span>
<span class="sd">        stores all the input variables as object attributes that do not</span>
<span class="sd">        change during simulation.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Check the initial position and make it an array.</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">X0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">X0</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="n">X0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.</span><span class="p">,</span> <span class="mf">0.</span><span class="p">,</span> <span class="n">X0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">X0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">X0</span><span class="p">)</span>

        <span class="c1"># Make sure yk is an ndarray</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">yk</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">yk</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="n">yk</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">yk</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">yk</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">yk</span><span class="p">)</span>

        <span class="c1"># Check if the right number of elements are in yk</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">yk</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">):</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Wrong number of mole fractions:&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;   yk : </span><span class="si">%d</span><span class="s1"> entries&#39;</span> <span class="o">%</span> <span class="nb">len</span><span class="p">(</span><span class="n">yk</span><span class="p">))</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;   composition : </span><span class="si">%d</span><span class="s1"> components</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                                    <span class="nb">len</span><span class="p">(</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">))</span>
            <span class="k">return</span>

        <span class="c1"># Save the input variables that are not part of the self.particle</span>
        <span class="c1"># object</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span> <span class="o">=</span> <span class="n">K_T</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">delta_t</span> <span class="o">=</span> <span class="n">delta_t</span>

        <span class="c1"># Get the initial conditions for the simulation run</span>
        <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="p">,</span> <span class="n">y0</span><span class="p">)</span> <span class="o">=</span> <span class="n">sbm_ic</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">X0</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">yk</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span>
                                     <span class="n">K</span><span class="p">,</span> <span class="n">K_T</span><span class="p">,</span> <span class="n">fdis</span><span class="p">,</span> <span class="n">t_hyd</span><span class="p">,</span> <span class="n">lag_time</span><span class="p">)</span>

        <span class="c1"># Open the simulation module</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">-- TEXAS A&amp;M OIL-SPILL CALCULATOR (TAMOC) --&#39;</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;-- Single Bubble Model                    --</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>

        <span class="c1"># Calculate the trajectory</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Calculate the trajectory...&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">calculate_path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span>
                                        <span class="n">y0</span><span class="p">,</span> <span class="n">delta_t</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Simulation complete.</span><span class="se">\n</span><span class="s1"> &#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Restart heat transfer</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">K_T</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span></div>

<div class="viewcode-block" id="Model.save_sim"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.save_sim.html#single_bubble_model.Model.save_sim">[docs]</a>    <span class="k">def</span> <span class="nf">save_sim</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fname</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span> <span class="n">profile_info</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save the current simulation results</span>

<span class="sd">        Save the current simulation results and the model parameters so that</span>
<span class="sd">        all information needed to rebuild the class object is stored in a</span>
<span class="sd">        file.  The output data are stored in netCDF4-classic format.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fname : str</span>
<span class="sd">            File name of the file to write</span>
<span class="sd">        profile_path : str</span>
<span class="sd">            String stating the file path relative to the directory where</span>
<span class="sd">            the output will be saved to the ambient profile data.</span>
<span class="sd">        profile_info : str</span>
<span class="sd">            Text describing the ambient profile data.</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        It does not make sense to store the ambient data together with every</span>
<span class="sd">        simulation output file.  On the other hand, the simulation results</span>
<span class="sd">        may be meaningless without the context of the ambient data.  The</span>
<span class="sd">        parameter `profile_path` provides a means to automatically load the</span>
<span class="sd">        ambient data assuming the profile data are kept in the same place</span>
<span class="sd">        relative to the output file.  Since this cannot be guaranteed, the</span>
<span class="sd">        `profile_info` variable provides additional descriptive information</span>
<span class="sd">        so that the ambient data can be identified if they have been moved.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results to store...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Saved nothing to netCDF file.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Create the netCDF dataset object</span>
        <span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;Simulation results for the TAMOC Single Bubble Model&#39;</span>
        <span class="n">nc</span> <span class="o">=</span> <span class="n">model_share</span><span class="o">.</span><span class="n">tamoc_nc_file</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span> <span class="n">profile_info</span><span class="p">)</span>

        <span class="c1"># Create variables for the dimensions</span>
        <span class="n">z</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;z&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;profile&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
        <span class="n">ns</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;ns&#39;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="mi">0</span><span class="p">,:]))</span>

        <span class="c1"># Create variables for the model initial conditions</span>
        <span class="n">K_T0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;K_T0&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;profile&#39;</span><span class="p">,))</span>
        <span class="n">K_T0</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Initial heat transfer reduction factor&#39;</span>
        <span class="n">K_T0</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;K_T0&#39;</span>
        <span class="n">K_T0</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;nondimensional&#39;</span>

        <span class="n">delta_t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;delta_t&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;profile&#39;</span><span class="p">,))</span>
        <span class="n">delta_t</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;maximum simulation output time step&#39;</span>
        <span class="n">delta_t</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;delta_t&#39;</span>
        <span class="n">delta_t</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;seconds&#39;</span>

        <span class="c1"># Create variables for the independent variable</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;z&#39;</span><span class="p">,))</span>
        <span class="n">t</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;time coordinate&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;time&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;seconds since release&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">axis</span> <span class="o">=</span> <span class="s1">&#39;T&#39;</span>

        <span class="c1"># Create variables for the state space</span>
        <span class="n">y</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;z&#39;</span><span class="p">,</span> <span class="s1">&#39;ns&#39;</span><span class="p">,))</span>
        <span class="n">y</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;solution state space&#39;</span>
        <span class="n">y</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;y&#39;</span>
        <span class="n">y</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;variable&#39;</span>
        <span class="n">y</span><span class="o">.</span><span class="n">coordinate</span> <span class="o">=</span> <span class="s1">&#39;t&#39;</span>

        <span class="c1"># Store the initial conditions and model setup</span>
        <span class="n">K_T0</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span>
        <span class="n">delta_t</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">delta_t</span>

        <span class="c1"># Store the dbm particle object</span>
        <span class="n">dispersed_phases</span><span class="o">.</span><span class="n">save_particle_to_nc_file</span><span class="p">(</span><span class="n">nc</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span><span class="p">)</span>

        <span class="c1"># Save the model simulation result</span>
        <span class="n">t</span><span class="p">[:]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">nc</span><span class="o">.</span><span class="n">dimensions</span><span class="p">[</span><span class="s1">&#39;ns&#39;</span><span class="p">])):</span>
            <span class="n">y</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">),</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span>

        <span class="c1"># Close the netCDF dataset</span>
        <span class="n">nc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>

<div class="viewcode-block" id="Model.save_txt"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.save_txt.html#single_bubble_model.Model.save_txt">[docs]</a>    <span class="k">def</span> <span class="nf">save_txt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">base_name</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span> <span class="n">profile_info</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save the state space in ascii text format for exporting</span>

<span class="sd">        Save the state space (dependent and independent variables) in an</span>
<span class="sd">        ascii text file for exporting to other programs (e.g., Matlab).</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        base_name : str</span>
<span class="sd">            The main name of the output file.  This method writes two files:</span>
<span class="sd">            the data are stored in base_name.txt, and the header information</span>
<span class="sd">            describing each row of data are saved in base_name_header.txt.</span>
<span class="sd">        profile_path : str</span>
<span class="sd">            String stating the file path relative to the directory where</span>
<span class="sd">            the output will be saved to the ambient profile data.</span>
<span class="sd">        profile_info : str</span>
<span class="sd">            Text describing the ambient profile data (less than 60</span>
<span class="sd">            characters).</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        The output data will be organized in columns, with each column</span>
<span class="sd">        as follows:</span>

<span class="sd">            0 : Time (s)</span>
<span class="sd">            1 : Depth (m)</span>
<span class="sd">            2 : (n-1) : Masses of the particle components (kg)</span>
<span class="sd">            n : Heat (m_p * cp * T) (J)</span>

<span class="sd">        A header will be written at the top of the file with the specific</span>
<span class="sd">        details for that file.</span>

<span class="sd">        The file is written using the `numpy.savetxt` method.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results to store...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Saved nothing to txt file.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Create the header string that contains the column descriptions</span>
        <span class="n">p_list</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Single Bubble Model ASCII Output File </span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">]</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Created: &#39;</span> <span class="o">+</span> <span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">()</span><span class="o">.</span><span class="n">isoformat</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Simulation based on CTD data in:</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">profile_path</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">profile_info</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Column Descriptions:</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    0:  Time in s</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    1:  x-coordinate in m</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    2:  y-coordinate in m</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    3:  Depth in m</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">)):</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">:  Mass of </span><span class="si">%s</span><span class="s1"> in particle in kg</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> \
                          <span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">4</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">:  Heat content (m_p * cp * T) in J</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">5</span><span class="p">))</span>
        <span class="n">header</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p_list</span><span class="p">)</span>

        <span class="c1"># Assemble and write the output data</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">np</span><span class="o">.</span><span class="n">atleast_2d</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">))</span>
        <span class="n">np</span><span class="o">.</span><span class="n">savetxt</span><span class="p">(</span><span class="n">base_name</span> <span class="o">+</span> <span class="s1">&#39;.txt&#39;</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">base_name</span> <span class="o">+</span> <span class="s1">&#39;_header.txt&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">txt_file</span><span class="p">:</span>
            <span class="n">txt_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">header</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.load_sim"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.load_sim.html#single_bubble_model.Model.load_sim">[docs]</a>    <span class="k">def</span> <span class="nf">load_sim</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fname</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Load in a saved simulation result file for post-processing</span>

<span class="sd">        Load in a saved simulation result file and rebuild the `Model`</span>
<span class="sd">        object attributes.  The input files are in netCDF4-classic data</span>
<span class="sd">        format.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fname : str</span>
<span class="sd">            File name of the file to read</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method will attempt to load the ambient profile data from the</span>
<span class="sd">        `profile_path` attribute of the `fname` netCDF file.  If the load</span>
<span class="sd">        fails, a warning will be reported to the terminal, but the other</span>
<span class="sd">        steps of loading the `Model` object attributes will be performed.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Open the netCDF dataset object containing the simulation results</span>
        <span class="n">nc</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="n">fname</span><span class="p">)</span>

        <span class="c1"># Try to open the profile data</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="o">=</span> <span class="n">model_share</span><span class="o">.</span><span class="n">profile_from_model_savefile</span><span class="p">(</span><span class="n">nc</span><span class="p">,</span> <span class="n">fname</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span> <span class="o">=</span> <span class="n">ModelParams</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># Load in the dispersed_phases.Particle object</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">particle</span> <span class="o">=</span> \
            <span class="n">dispersed_phases</span><span class="o">.</span><span class="n">load_particle_from_nc_file</span><span class="p">(</span><span class="n">nc</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>

        <span class="c1"># Extract the state space data</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;t&#39;</span><span class="p">][:]</span>
        <span class="n">ns</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">nc</span><span class="o">.</span><span class="n">dimensions</span><span class="p">[</span><span class="s1">&#39;ns&#39;</span><span class="p">])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">),</span> <span class="n">ns</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;y&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">),</span> <span class="n">i</span><span class="p">]</span>

        <span class="c1"># Extract the initial conditions</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;K_T0&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">delta_t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;delta_t&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>

        <span class="c1"># Close the netCDF dataset</span>
        <span class="n">nc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="Model.post_process"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.Model.post_process.html#single_bubble_model.Model.post_process">[docs]</a>    <span class="k">def</span> <span class="nf">post_process</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fig</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the simulation state space and key interrogation parameters</span>

<span class="sd">        Plot the standard set of post-processing figures, including the</span>
<span class="sd">        state space and the key derived variables.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fig : int</span>
<span class="sd">            Figure number to pass to the plotting methods</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        plot_state_space</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results to plot...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Plotting nothing.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Plot the results</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Plotting the results...&#39;</span><span class="p">)</span>
        <span class="n">plot_state_space</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">,</span>
                         <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">fig</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Done.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="ModelParams"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.ModelParams.html#single_bubble_model.ModelParams">[docs]</a><span class="k">class</span> <span class="nc">ModelParams</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Fixed model parameters for the single bubble model</span>

<span class="sd">    This class stores the set of model parameters that should not be adjusted</span>
<span class="sd">    by the user and that are needed by the single bubble model.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        The ambient CTD object used by the single bubble model simulation.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    rho_r : float</span>
<span class="sd">        Reference density (kg/m^3) evaluated at mid-depth of the water body.</span>
<span class="sd">    g : float</span>
<span class="sd">        Acceleration of gravity (m/s^2)</span>
<span class="sd">    Ru : float</span>
<span class="sd">        Ideal gas constant (J/mol/K)</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="ModelParams.__init__"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.ModelParams.html#single_bubble_model.ModelParams.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ModelParams</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="c1"># Store a reference density for the water column</span>
        <span class="n">z_ave</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">z_max</span> <span class="o">-</span> <span class="p">(</span><span class="n">profile</span><span class="o">.</span><span class="n">z_max</span> <span class="o">-</span> <span class="n">profile</span><span class="o">.</span><span class="n">z_min</span><span class="p">)</span> <span class="o">/</span> <span class="mf">2.</span>
        <span class="n">T</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">P</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">z_ave</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span> <span class="s1">&#39;salinity&#39;</span><span class="p">,</span>
                                     <span class="s1">&#39;pressure&#39;</span><span class="p">])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho_r</span> <span class="o">=</span> <span class="n">seawater</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">P</span><span class="p">)</span>

        <span class="c1"># Store some physical constants</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">g</span> <span class="o">=</span> <span class="mf">9.81</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Ru</span> <span class="o">=</span> <span class="mf">8.314510</span></div></div>


<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Functions to compute the trajectory</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="calculate_path"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.calculate_path.html#single_bubble_model.calculate_path">[docs]</a><span class="k">def</span> <span class="nf">calculate_path</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">y0</span><span class="p">,</span> <span class="n">delta_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Calculate the trajectory of a particle</span>

<span class="sd">    Calculate the trajectory of a particle by integrating its path using</span>
<span class="sd">    the `scipy.integrate.ode` object and associated methods.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Ambient CTD data for the model simulation</span>
<span class="sd">    particle : `LagrangianParticle` object</span>
<span class="sd">        Object describing the properties and behavior of the particle.</span>
<span class="sd">    p : `ModelParams` object</span>
<span class="sd">        Collection of model parameters passed to `derivs`.</span>
<span class="sd">    y0 : ndarray</span>
<span class="sd">        Initial values of the state space (depth in m, masses in kg, and heat</span>
<span class="sd">        content in J of the particle) at the release point</span>
<span class="sd">    delta_t : float</span>
<span class="sd">        Maximum step size (s) to take in the integration</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    The differential equation in `derivs` is written with respect to time, so</span>
<span class="sd">    the independent variable in this simulation is time.  The vertical</span>
<span class="sd">    coordinate; therefore, becomes a dependent variable, along with the masses</span>
<span class="sd">    of each component in the particle and the particle temperature.  Thus,</span>
<span class="sd">    the state space is::</span>

<span class="sd">        y = np.hstack((z0, m0, H0))</span>

<span class="sd">    where `H0` is the initial heat content, `m_p * cp * T0`.  The variables</span>
<span class="sd">    in the state space can be returned by::</span>

<span class="sd">        &gt;&gt;&gt; import seawater</span>
<span class="sd">        &gt;&gt;&gt; z = y[2]</span>
<span class="sd">        &gt;&gt;&gt; m = y[3:-1]</span>
<span class="sd">        &gt;&gt;&gt; T = y[-1] / (np.sum(y[1:-1]) * particle.cp)</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Create the integrator object:  use &quot;vode&quot; with &quot;backward</span>
    <span class="c1"># differentiation formula&quot; for stiff ODEs</span>
    <span class="n">r</span> <span class="o">=</span> <span class="n">integrate</span><span class="o">.</span><span class="n">ode</span><span class="p">(</span><span class="n">derivs</span><span class="p">)</span><span class="o">.</span><span class="n">set_integrator</span><span class="p">(</span><span class="s1">&#39;vode&#39;</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">&#39;bdf&#39;</span><span class="p">,</span> <span class="n">atol</span><span class="o">=</span><span class="mf">1.e-6</span><span class="p">,</span>
        <span class="n">rtol</span><span class="o">=</span><span class="mf">1e-3</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">max_step</span><span class="o">=</span><span class="n">delta_t</span><span class="p">)</span>

    <span class="c1"># Initialize the state space</span>
    <span class="n">t0</span> <span class="o">=</span> <span class="mf">0.</span>
    <span class="n">r</span><span class="o">.</span><span class="n">set_initial_value</span><span class="p">(</span><span class="n">y0</span><span class="p">,</span> <span class="n">t0</span><span class="p">)</span>

    <span class="c1"># Set passing variables for derivs method</span>
    <span class="n">r</span><span class="o">.</span><span class="n">set_f_params</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>

    <span class="c1"># Create vectors (using the list data type) to store the solution</span>
    <span class="n">t</span> <span class="o">=</span> <span class="p">[</span><span class="n">t0</span><span class="p">]</span>
    <span class="n">y</span> <span class="o">=</span> <span class="p">[</span><span class="n">y0</span><span class="p">]</span>

    <span class="c1"># Integrate to the free surface (profile.z_min)</span>
    <span class="n">k</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">psteps</span> <span class="o">=</span> <span class="mf">10.</span>
    <span class="n">stop</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="k">while</span> <span class="n">r</span><span class="o">.</span><span class="n">successful</span><span class="p">()</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">stop</span><span class="p">:</span>

        <span class="c1"># Print progress to the screen</span>
        <span class="n">m0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">mt</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">f</span> <span class="o">=</span> <span class="n">mt</span> <span class="o">/</span> <span class="n">m0</span>
        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">remainder</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">(</span><span class="n">k</span><span class="p">),</span> <span class="n">psteps</span><span class="p">)</span> <span class="o">==</span> <span class="mf">0.</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;    Depth:  </span><span class="si">%g</span><span class="s1"> (m), t:  </span><span class="si">%g</span><span class="s1"> (s), k: </span><span class="si">%d</span><span class="s1">, f: </span><span class="si">%g</span><span class="s1"> (--)&#39;</span> <span class="o">%</span>
                <span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">t</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">k</span><span class="p">,</span> <span class="n">f</span><span class="p">))</span>

        <span class="c1"># Perform one step of the integration</span>
        <span class="n">r</span><span class="o">.</span><span class="n">integrate</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">delta_t</span><span class="p">,</span> <span class="n">step</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="c1"># Store the results</span>
        <span class="k">if</span> <span class="n">particle</span><span class="o">.</span><span class="n">K_T</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="c1"># Make the state-space heat correct</span>
            <span class="n">Ta</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s1">&#39;temperature&#39;</span><span class="p">)</span>
            <span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">*</span> <span class="n">particle</span><span class="o">.</span><span class="n">cp</span> <span class="o">*</span> <span class="n">Ta</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">])):</span>
            <span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">3</span><span class="p">]</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">:</span>
                <span class="c1"># Concentration should not overshoot zero</span>
                <span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.</span>
        <span class="n">t</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">t</span><span class="p">)</span>
        <span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">)</span>
        <span class="n">k</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="c1"># Evaluate stop criteria</span>
        <span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">successful</span><span class="p">():</span>
            <span class="c1"># Check if bubble dissolved (us = 0 or based on fdis) or reached </span>
            <span class="c1"># the free surface</span>
            <span class="n">us</span> <span class="o">=</span> <span class="o">-</span> <span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">y</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">t</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">y</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="n">profile</span><span class="o">.</span><span class="n">z_min</span> <span class="ow">or</span> <span class="n">us</span> <span class="o">&lt;=</span> <span class="mf">0.</span> <span class="ow">or</span> <span class="n">f</span> <span class="o">&lt;</span> <span class="n">particle</span><span class="o">.</span><span class="n">fdis</span><span class="p">:</span>
                <span class="n">stop</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">if</span> <span class="n">k</span> <span class="o">&gt;</span> <span class="mi">5000</span><span class="p">:</span>
                <span class="n">stop</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="c1"># Remove any negative depths due to overshooting the free surface</span>
    <span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
    <span class="n">rows</span> <span class="o">=</span> <span class="n">y</span><span class="p">[:,</span><span class="mi">2</span><span class="p">]</span> <span class="o">&gt;=</span> <span class="mi">0</span>
    <span class="n">t</span> <span class="o">=</span> <span class="n">t</span><span class="p">[</span><span class="n">rows</span><span class="p">]</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">y</span><span class="p">[</span><span class="n">rows</span><span class="p">,:]</span>

    <span class="c1"># Return the solution</span>
    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;    Depth:  </span><span class="si">%g</span><span class="s1"> (m), t:  </span><span class="si">%g</span><span class="s1"> (s), k: </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span>
        <span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">],</span> <span class="n">t</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">k</span><span class="p">))</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span></div>


<div class="viewcode-block" id="derivs"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.derivs.html#single_bubble_model.derivs">[docs]</a><span class="k">def</span> <span class="nf">derivs</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">p</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Compute the RHS of the ODE for the trajectory of a single particle</span>

<span class="sd">    Compute the right-hand-side of the governing system of ordinary</span>
<span class="sd">    differential equations for the trajectory of a single particle rising</span>
<span class="sd">    through the water column.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    t : float</span>
<span class="sd">        Current simulation time (s)</span>
<span class="sd">    y : ndarray</span>
<span class="sd">        Model state space.  Includes the current depth (m), the masses (kg)</span>
<span class="sd">        of each component of the particle, and the particle heat content</span>
<span class="sd">        (J)</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Ambient CTD data for the model simulation</span>
<span class="sd">    particle : `LagrangianParticle` object</span>
<span class="sd">        Object describing the properties and behavior of the particle.</span>
<span class="sd">    p : `ModelParams` object</span>
<span class="sd">        Object containing the model parameters</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This function is called by the ODE solver `scipy.integrate.ode`.  This</span>
<span class="sd">    function should not generally be called by the user.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Set up the output variable</span>
    <span class="n">yp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">y</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>

    <span class="c1"># Extract the state space variables for speed and ease of reading code</span>
    <span class="n">z</span> <span class="o">=</span> <span class="n">y</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
    <span class="n">m</span> <span class="o">=</span> <span class="n">y</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">y</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> <span class="o">*</span> <span class="n">particle</span><span class="o">.</span><span class="n">cp</span><span class="p">)</span>

    <span class="c1"># Get the ambient profile data</span>
    <span class="n">Ta</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">P</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span> <span class="s1">&#39;salinity&#39;</span><span class="p">,</span> <span class="s1">&#39;pressure&#39;</span><span class="p">])</span>
    <span class="n">ua</span><span class="p">,</span> <span class="n">va</span><span class="p">,</span> <span class="n">wa</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;ua&#39;</span><span class="p">,</span> <span class="s1">&#39;va&#39;</span><span class="p">,</span> <span class="s1">&#39;wa&#39;</span><span class="p">])</span>
    <span class="n">C</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">)</span>

    <span class="c1"># Get the physical particle properties</span>
    <span class="p">(</span><span class="n">us</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">A</span><span class="p">,</span> <span class="n">Cs</span><span class="p">,</span> <span class="n">beta</span><span class="p">,</span> <span class="n">beta_T</span><span class="p">,</span> <span class="n">T</span><span class="p">)</span> <span class="o">=</span> <span class="n">particle</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="n">P</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span>
                                                              <span class="n">Ta</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span>
    <span class="c1"># Get the biodegradation rate constants</span>
    <span class="n">k_bio</span> <span class="o">=</span> <span class="n">particle</span><span class="o">.</span><span class="n">biodegradation_rate</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>

    <span class="c1"># Advection</span>
    <span class="n">yp</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">ua</span>
    <span class="n">yp</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">va</span>
    <span class="n">yp</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="n">us</span> <span class="o">-</span> <span class="n">wa</span>

    <span class="c1"># Dissolution</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">Cs</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
        <span class="n">md_diss</span> <span class="o">=</span> <span class="o">-</span> <span class="n">A</span> <span class="o">*</span> <span class="n">beta</span><span class="p">[:]</span> <span class="o">*</span> <span class="p">(</span><span class="n">Cs</span><span class="p">[:]</span> <span class="o">-</span> <span class="n">C</span><span class="p">[:])</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">md_diss</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.</span><span class="p">])</span>

    <span class="c1"># Biodegradation</span>
    <span class="n">md_biodeg</span> <span class="o">=</span> <span class="o">-</span><span class="n">k_bio</span> <span class="o">*</span> <span class="n">m</span>
    <span class="n">yp</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">md_diss</span> <span class="o">+</span> <span class="n">md_biodeg</span>

    <span class="c1"># Account for heat transfer (ignore heat of solution since it is</span>
    <span class="c1"># negligible in the beginning as the particle approaches equilibrium)</span>
    <span class="n">yp</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span>  <span class="o">-</span> <span class="n">rho_p</span> <span class="o">*</span> <span class="n">particle</span><span class="o">.</span><span class="n">cp</span> <span class="o">*</span> <span class="n">A</span> <span class="o">*</span> <span class="n">beta_T</span> <span class="o">*</span> <span class="p">(</span><span class="n">T</span> <span class="o">-</span> <span class="n">Ta</span><span class="p">)</span>

    <span class="c1"># Account for heat lost due to decrease in mass</span>
    <span class="n">yp</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+=</span> <span class="n">particle</span><span class="o">.</span><span class="n">cp</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">md_diss</span> <span class="o">+</span> <span class="n">md_biodeg</span><span class="p">)</span> <span class="o">*</span> <span class="n">T</span>

    <span class="c1"># Return the derivatives</span>
    <span class="k">return</span> <span class="n">yp</span></div>


<div class="viewcode-block" id="sbm_ic"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.sbm_ic.html#single_bubble_model.sbm_ic">[docs]</a><span class="k">def</span> <span class="nf">sbm_ic</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">X0</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">yk</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span> <span class="n">K</span><span class="p">,</span> <span class="n">K_T</span><span class="p">,</span> <span class="n">fdis</span><span class="p">,</span> <span class="n">t_hyd</span><span class="p">,</span> <span class="n">lag_time</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Set the initial conditions for a single bubble model simulation</span>

<span class="sd">    Set up the state space at the release point for the single bubble model</span>
<span class="sd">    simulation</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Ambient CTD data for the model simulation</span>
<span class="sd">    particle : `dbm.FluidParticle` or `dbm.InsolubleParticle` object</span>
<span class="sd">        Object describing the properties and behavior of the particle.</span>
<span class="sd">    X0 : ndarray</span>
<span class="sd">        The release location (x, y, y) in m of the particle in the simulation</span>
<span class="sd">    de : float</span>
<span class="sd">        Initial diameter of the particle (m)</span>
<span class="sd">    yk : ndarray</span>
<span class="sd">        Initial mole fractions of each component in the particle (--)</span>
<span class="sd">    T0 : float, optional</span>
<span class="sd">        Initial temperature (K) of the particle at release if not equal</span>
<span class="sd">        to the temperature of the surrounding fluid.  If omitted, the</span>
<span class="sd">        model will set T0 to the ambient temperature.</span>
<span class="sd">    K : float</span>
<span class="sd">        Mass transfer reduction factor (--). Pre-multiplies the mass</span>
<span class="sd">        transfer coefficients providing amplification (&gt;1) or retardation</span>
<span class="sd">        (&lt;1) of the dissolution.</span>
<span class="sd">    K_T : float</span>
<span class="sd">        Heat transfer reduction factor (--). Pre-multiplies the heat</span>
<span class="sd">        transfer coefficient providing amplification (&gt;1) or retardation</span>
<span class="sd">        (&lt;1) of the heat flux.</span>
<span class="sd">    fdis : float</span>
<span class="sd">        Fraction of the initial total mass (--) remaining when the</span>
<span class="sd">        particle should be considered dissolved.</span>
<span class="sd">    t_hyd : float</span>
<span class="sd">        Hydrate film formation time (s).  Mass transfer is computed by clean</span>
<span class="sd">        bubble methods for t less than t_hyd and by dirty bubble methods</span>
<span class="sd">        thereafter.  The default behavior is to assume the particle is dirty</span>
<span class="sd">        or hydrate covered from the release.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    particle : `LagrangianParticle` object</span>
<span class="sd">        A `LagrangianParticle` object containing a unified interface to the</span>
<span class="sd">        `dbm` module and the particle-specific model parameters (e.g., mass</span>
<span class="sd">        transfer reduction factor, etc.)</span>
<span class="sd">    y0 : ndarray</span>
<span class="sd">        Model state space at the release point.  Includes the current depth</span>
<span class="sd">        (m), the masses (kg) of each component of the particle, and the</span>
<span class="sd">        particle heat content (J)</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This function converts an initial diameter and a list of mole fractions</span>
<span class="sd">    to the actual mass of each component in a particle.  This seems like</span>
<span class="sd">    the most common method a single particle would be initialized.  Note,</span>
<span class="sd">    however, that the user does not specify the mass: it is calculated in</span>
<span class="sd">    this function.  If the same diameter particle is released as a deeper</span>
<span class="sd">    depth, it will contain more mass (due to compressibility).  Likewise,</span>
<span class="sd">    if the composition is changed while the depth and diameter are</span>
<span class="sd">    maintained constant, the mass will change, altering the trajectory</span>
<span class="sd">    and simulation results.  If the mass is to be kept constant, this must</span>
<span class="sd">    be done outside this routine and the correct diameter calculated and</span>
<span class="sd">    passed to this function.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Get the particle initial conditions from the dispersed_phases module</span>
    <span class="n">m0</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span> <span class="n">nb0</span><span class="p">,</span> <span class="n">P</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Ta</span> <span class="o">=</span> <span class="n">dispersed_phases</span><span class="o">.</span><span class="n">initial_conditions</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span>
        <span class="n">X0</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">particle</span><span class="p">,</span> <span class="n">yk</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">T0</span><span class="p">)</span>

    <span class="c1"># Initialize a LagrangianParticle object</span>
    <span class="n">particle</span> <span class="o">=</span> <span class="n">dispersed_phases</span><span class="o">.</span><span class="n">SingleParticle</span><span class="p">(</span><span class="n">particle</span><span class="p">,</span> <span class="n">m0</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span> <span class="n">K</span><span class="p">,</span> <span class="n">K_T</span><span class="p">,</span>
               <span class="n">fdis</span><span class="p">,</span> <span class="n">t_hyd</span><span class="p">,</span> <span class="n">lag_time</span><span class="p">)</span>

    <span class="c1"># Assemble the state space</span>
    <span class="n">y0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">X0</span><span class="p">,</span> <span class="n">m0</span><span class="p">,</span> <span class="n">T0</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m0</span><span class="p">)</span> <span class="o">*</span> <span class="n">particle</span><span class="o">.</span><span class="n">cp</span><span class="p">))</span>

    <span class="c1"># Return the particle object and the state space</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">particle</span><span class="p">,</span> <span class="n">y0</span><span class="p">)</span></div>


<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Functions to post process the simulation solution</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="plot_state_space"><a class="viewcode-back" href="../autodoc/sbm/single_bubble_model.plot_state_space.html#single_bubble_model.plot_state_space">[docs]</a><span class="k">def</span> <span class="nf">plot_state_space</span><span class="p">(</span><span class="n">profile</span><span class="p">,</span> <span class="n">particle</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">fig</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Create the basic plots to interrogate the solution for the particle path</span>

<span class="sd">    Plots the basic state space variables for a solution of the particle</span>
<span class="sd">    trajectory.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        Ambient CTD data for the model simulation</span>
<span class="sd">    particle : `LagrangianParticle` object</span>
<span class="sd">        Object describing the properties and behavior of the particle.</span>
<span class="sd">    p : `ModelParams` object</span>
<span class="sd">        Collection of model parameters passed to `derivs`.</span>
<span class="sd">    t : ndarray</span>
<span class="sd">        Times (s) associated with the state space for the trajectory of the</span>
<span class="sd">        particle</span>
<span class="sd">    y : ndarray</span>
<span class="sd">        State space along the trajectory of the particle.  The state space</span>
<span class="sd">        includes the location (m), masses (kg) of the particle components, and</span>
<span class="sd">        the particle heat content (J).  Each variable is contained in a</span>
<span class="sd">        separate column of `y`.</span>
<span class="sd">    fig : int</span>
<span class="sd">        Figure number to place the first of the plots.</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    Creates three figure windows:</span>

<span class="sd">    1. State space variables versus time</span>
<span class="sd">    2. Particle diameter, shape, density, and temperature</span>
<span class="sd">    3. Solubility, mass transfer, and surface area</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># imported here so MPL will only be imported if you need it.</span>
    <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
    <span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>

    <span class="c1"># Extract the state space variables</span>

    <span class="n">xi</span> <span class="o">=</span> <span class="n">y</span><span class="p">[:,</span><span class="mi">0</span><span class="p">]</span>
    <span class="n">yi</span> <span class="o">=</span> <span class="n">y</span><span class="p">[:,</span><span class="mi">1</span><span class="p">]</span>
    <span class="n">zi</span> <span class="o">=</span> <span class="n">y</span><span class="p">[:,</span><span class="mi">2</span><span class="p">]</span>
    <span class="n">m</span> <span class="o">=</span> <span class="n">y</span><span class="p">[:,</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m</span><span class="p">[</span><span class="n">i</span><span class="p">,:])</span> <span class="o">*</span> <span class="n">particle</span><span class="o">.</span><span class="n">cp</span><span class="p">)</span>
                 <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">zi</span><span class="p">))])</span>

    <span class="c1"># Compute the diameter and save the ambient temperature</span>
    <span class="n">rho_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">Cs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">len</span><span class="p">(</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">)))</span>
    <span class="n">beta</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">len</span><span class="p">(</span><span class="n">particle</span><span class="o">.</span><span class="n">composition</span><span class="p">)))</span>
    <span class="n">Ta</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">shape</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">de</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">us</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">P</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">Sa</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">N</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">T_fun</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">)):</span>
        <span class="n">Ta</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Sa</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">P</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">zi</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span>
                             <span class="s1">&#39;salinity&#39;</span><span class="p">,</span> <span class="s1">&#39;pressure&#39;</span><span class="p">])</span>
        <span class="n">N</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">buoyancy_frequency</span><span class="p">(</span><span class="n">zi</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">h</span><span class="o">=</span><span class="mf">0.005</span><span class="p">)</span>
        <span class="p">(</span><span class="n">us</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">rho_p</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Cs_local</span><span class="p">,</span> <span class="n">beta_local</span><span class="p">,</span> <span class="n">beta_T</span><span class="p">,</span> <span class="n">T_fun</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">=</span> \
            <span class="n">particle</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">m</span><span class="p">[</span><span class="n">i</span><span class="p">,:],</span> <span class="n">T</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">P</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Sa</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Ta</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">t</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">Cs_local</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">Cs</span><span class="p">[</span><span class="n">i</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">Cs_local</span>
            <span class="n">beta</span><span class="p">[</span><span class="n">i</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">beta_local</span>
        <span class="n">shape</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">particle</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">particle_shape</span><span class="p">(</span><span class="n">m</span><span class="p">[</span><span class="n">i</span><span class="p">,:],</span> <span class="n">T</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">P</span><span class="p">[</span><span class="n">i</span><span class="p">],</span>
                   <span class="n">Sa</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Ta</span><span class="p">[</span><span class="n">i</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">de</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">particle</span><span class="o">.</span><span class="n">diameter</span><span class="p">(</span><span class="n">m</span><span class="p">[</span><span class="n">i</span><span class="p">,:],</span> <span class="n">T</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">P</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Sa</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">Ta</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>

    <span class="c1"># Start by plotting the raw state space versus t</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>

    <span class="c1"># Depth</span>
    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">zi</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Time (s)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Slip Velocity</span>
    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">us</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Slip velocity (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Masses</span>
    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Component masses (kg)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="c1">#ax3.xaxis.set_major_locator(mpl.ticker.LogLocator(base=1e2))</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Heat</span>
    <span class="n">ax4</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="n">y</span><span class="p">[:,</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">t</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Heat (J)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="c1">#ax4.xaxis.set_major_locator(mpl.ticker.LogLocator(base=1e2))</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot derived variables related to diameter</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>

    <span class="c1"># Diameter</span>
    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="n">de</span> <span class="o">*</span> <span class="mi">1000</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Diameter (mm)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="c1">#ax1.xaxis.set_major_locator(mpl.ticker.LogLocator(base=1e2))</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Shape</span>
    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Shape (--)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Density</span>
    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">rho_p</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Density (kg)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Temperature</span>
    <span class="n">ax4</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">T</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">T_fun</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">Ta</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (K)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot dissolution data</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="o">+</span><span class="mi">2</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>

    <span class="c1"># Masses</span>
    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Component masses (kg)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="c1">#ax1.xaxis.set_major_locator(mpl.ticker.LogLocator(base=1e2))</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Solubility</span>
    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">Cs</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Solubility (kg/m^3)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Mass transfer coefficient</span>
    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">beta</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Mass transfer (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">&#39;sci&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="n">scilimits</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">))</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="c1"># Area</span>
    <span class="n">ax4</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="n">A</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Surface area (m^2)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="c1">#ax4.xaxis.set_major_locator(mpl.ticker.LogLocator(base=1e2))</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot dissolution data</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="o">+</span><span class="mi">3</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>

    <span class="c1"># CTD Temperature</span>
    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">Ta</span> <span class="o">-</span> <span class="mf">273.15</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (deg C)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">Sa</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Salinity (psu)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">P</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Pressure (Pa)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">ax4</span><span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">zi</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Buoyancy Frequency (1/s)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">locator_params</span><span class="p">(</span><span class="n">tight</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span></div>

</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>